home *** CD-ROM | disk | FTP | other *** search
- {$G2048,P2048,D-}
- program widths;
- {-----------------------------------------------------------------------}
- { }
- { Reduce Roman-8 Font Files to USASCII Font Files }
- { }
- { usascii SOURCE DESTINATION }
- { (using DOS redirection facilities) }
- { }
- {-----------------------------------------------------------------------}
-
- {--------------- Font Descriptor -------------------------------------}
- type
-
- FontMap = record
- {+ 0} Res0: integer;
- {+ 2} Res1: byte;
- {+ 3} FontType: byte;
- {+ 4} Res2: integer;
- {+ 6} Baseline: integer;
- {+ 8} CellWidth: integer;
- {+10} CellHeight: integer;
- {+12} Orientation: byte;
- {+13} FixedProp: byte;
- {+14} SymbolSet: integer;
- {+16} Pitch: integer;
- {+18} Height: integer;
- {+20} Res3: integer;
- {+22} Res4: byte;
- {+23} Style: byte;
- {+24} StrokeWeight: byte;
- {+25} Typeface: byte;
- end;
-
- {--------------- Character Descriptor --------------------------------}
- CharMap = record
- {+ 0} Res0: integer;
- {+ 2} Res1: integer;
- {+ 4} Orientation: char;
- {+ 5} Res2: byte;
- {+ 6} LeftOffset: integer;
- {+ 8} TopOffset: integer;
- {+10} CharWidth: integer;
- {+12} CharHeight: integer;
- {+14} DeltaX: integer;
- end;
-
- HpFont = record
- case Boolean of
- True: (Tab: array[0..25] of Char);
- False: (Def: FontMap);
-
- end;
-
- HpChar = record
- case Boolean of
- True: (Tab: array[0..15] of Char);
- False: (Def: CharMap);
- end;
-
- Var
-
- CC, i, j : integer;
- FontDesc : HpFont;
- CharDesc : HpChar;
- Nextc : char;
- Char1, Char2, Char3 : char;
- NumStr : string[5];
- Skip : integer;
- CharCode : integer;
-
- label
-
- quit;
-
-
- begin
-
- WriteLn(Con, 'USASCII v1.01');
- WriteLn(Con, 'Denis DeLaRoca, 1987');
-
- {------ Make Sure File starts with Font Desc: "^[)s" ----------------}
-
- read(Char1, Char2, Char3);
- if (Char1 <> #$1b) or (Char2 <> ')') or (Char3 <> 's')
- then begin
- writeln('*** Missing Font Descriptor');
- halt(1);
- end;
-
- {------ Extract Length of Descriptor + Data ------------------------}
-
- NumStr := '';
- read(Nextc);
- while nextc <> 'W' do
- begin
- NumStr := NumStr + nextc;
- read(nextc);
- end;
- Val(NumStr, Skip, CC);
- if CC <> 0
- then begin
- writeln('*** Bad Font Descriptor Length');
- halt(2);
- end;
-
- {------ Read Font Descriptor Header and Output Some Parms ----------}
-
- for i := 0 to 25
- do read(FontDesc.Tab[i]);
- with FontDesc, Def do
- begin
- FontType := 0; { Force FontType to "7-bit" }
- SymbolSet := 21; { Force Symbol Set to "21" }
- SymbolSet := Swap(SymbolSet);
- end;
-
- {------ Write Font Descriptor to Output File ------------------------}
-
- Write(Char1, Char2, Char3, NumStr, 'W');
- for i := 0 to 25
- do Write(FontDesc.Tab[i]);
-
- {------ Transfer Rest of Font Descriptor Data ------------------------}
-
- Skip := Skip - 26;
- for i := 1 to skip do
- begin
- Read(Nextc);
- Write(Nextc);
- end;
-
- {------ Now Start Main Loop, Copy Char Id's and Descriptors ---------}
-
- repeat
- repeat
- read(Char1);
- until (Char1 = #$1b);
- read(Char2, Char3);
- until (Char2 = '*') and (Char3 = 'c');
-
- {------ Validate Char Code Descriptor --------------------------------}
-
- while ((not EOF) and (Char1 <> #$00)) do
- begin
- if (Char1 <> #$1b) or (Char2 <> '*') or (Char3 <> 'c')
- then begin
- writeln('*** Bad Char Code Desc');
- halt(3);
- end;
-
- {------ Extract Char Code Value --------------------------------------}
-
- NumStr := '';
- Read(Nextc);
- while nextc <> 'E' do
- begin
- NumStr := NumStr + Nextc;
- Read(Nextc);
- end;
- Val(NumStr, CharCode, CC);
-
- {------ Find End of USASCII Font, Write Char-id Desc -----------------}
-
- If CharCode >= 128
- then goto quit;
- Write(Char1, Char2, Char3, NumStr, 'E');
-
- {------ Validate Char Font Descriptor -------------------------------}
-
- Read(Char1,Char2, Char3);
- if (Char1 <> #$1b) or (Char2 <> '(') or (Char3 <> 's')
- then begin
- writeln('*** Bad Char Descriptor');
- halt(4);
- end;
-
- {------ Extract Length of Descriptor + Data -------------------------}
-
- NumStr := '';
- Read(Nextc);
- while nextc <> 'W' do
- begin
- NumStr := NumStr + Nextc;
- Read(Nextc);
- end;
- Val(NumStr, Skip, CC);
-
- {------ Duplicate Char Font Descriptor -------------------------------}
-
- Write(Char1, Char2, Char3, NumStr, 'W');
- for i := 0 to 15 do
- begin
- Read(Nextc);
- Write(Nextc);
- end;
-
- {------ Duplicate Char Font Data -------------------------------------}
-
- Skip := Skip - 16;
- for i := 1 to Skip do
- begin
- Read(Nextc);
- Write(Nextc);
- end;
-
- {------ Try to Fetch Next Char Code Descriptor ----------------------}
-
- Read(Char1, Char2, Char3);
- end;
-
- quit:
-
- end.